local shenglongjindun = fk.CreateSkill{
  name = "shenglongjindun",
  tags = { Skill.Wake },
}

Fk:loadTranslationTable{
  ["shenglongjindun"] = "圣龙金盾",
  [":shenglongjindun"] = "觉醒技，当你进入濒死状态时，你变身为圣盾形态，失去技能【金锋】，获得技能【圣盾】，并再触发一次【不灭龙躯】的效果。",
  ["#shenglongjindun"] = "圣龙金盾：是否变为圣盾形态？",
}

shenglongjindun:addEffect(fk.EnterDying, {
  anim_type = "special",
  can_trigger = function(self, event, target, player, data)
    return target == player 
    and player:hasSkill("tiancaijinfeng") 
    and not player:hasSkill("shengdunhuanglin")
    and player:usedSkillTimes(self.name, Player.HistoryGame) == 0
    and player.maxHp > 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player:isWounded() then
      room:recover { 
        num = player.maxHp - player.hp, 
        skillName = self.name, 
        who = player, 
        recoverBy = player 
      }
    end
    if player.general == "huangjinshenglong" then
      room:setPlayerProperty(player, "general", "huangjindun")
    end
    if player.deputyGeneral == "huangjinshenglong" then
      room:setPlayerProperty(player, "deputyGeneral", "huangjindun")
    end
    --删除技能
    room:handleAddLoseSkills(player, "-tiancaijinfeng")
    -- 添加维舍斯技能
    room:handleAddLoseSkills(player, "shengdunhuanglin", nil, true, false)
    local armor = math.floor(player.maxHp)
    for _, p in ipairs(room:getAlivePlayers()) do
        room:changeShield(p,armor)
    end
  end,
})

return shenglongjindun 